<template>
    <div class="flx">
        <div class="panel panel-primary" style="margin:8px;"  v-for="(value,key,index) in result" :key="index">
            <div class="panel-heading">{{key}}</div>
            <!-- List group -->
            <!-- <ul class="list-group">
                <li class="list-group-item">检验结果：{{item['检验结果']}}</li>
                <li class="list-group-item">结果单位：{{item['结果单位']}}</li>
                <li class="list-group-item">结果标志：<span :class="item['结果标志']">{{item['结果标志']}}</span></li>
                <li class="list-group-item">参考范围：{{item['参考范围']}}</li>
            </ul> -->
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>检验结果</th>
                        <th>结果单位</th>
                        <th>结果标志</th>
                        <th>参考范围</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item,idx) in value" :key="idx">
                        <!-- <template v-for="(value,key,index) in item">
                            <td v-if="index>0" :key="">{{value}}</td>
                        </template>> -->
                        <td>{{item['报告项目名称']}}</td>
                        <td>{{item['检验结果']}}</td>
                        <td>{{item['结果单位']}}</td>
                        <td><span :class="item['结果标志']">{{item['结果标志']}}</span></td>
                        <td>{{item['参考范围']}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return {
            result:null
        }
    },
    created(){
        this.getResult()
    },
    methods:{
        getResult(){
            var admDate = this.$route.query.admDate
            this.$store.commit('setLoading',true)
            this.$api.getResult(admDate).then(res=>{
                this.$store.commit('setLoading',false)
                const ret=res.data;
                if(ret.length>0){
                    this.result={};
                    ret.forEach(item=>{
                        if(!this.result[item['体检目的']]){
                            this.result[item['体检目的']]=[];
                        }
                        this.result[item['体检目的']].push(item)
                    })
                    console.log(this.result)
                }
                
            })
        }
    }
}
</script>
<style>
.L{
    color: #f60;
}
.M{
    color: seagreen;
}
.H{
    color: red;
}
</style>